home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ARASAN_S.ZIP / CLOCK.H < prev    next >
C/C++ Source or Header  |  1994-09-28  |  2KB  |  89 lines

  1. // Copyright 1993 by Jon Dart.  All Rights Reserved.
  2.  
  3. #ifndef _CLOCK_H
  4. #define _CLOCK_H
  5.  
  6. #include "color.h"
  7. #include "types.h"
  8. #include <time.h>
  9. #include <windows.h>
  10.  
  11. class Clock
  12. {
  13. public:
  14.     enum Direction { Up, Down };
  15.  
  16.     Clock( HWND parent );
  17.     
  18.     virtual ~Clock();
  19.     
  20.     void set_handle( const HWND parent );
  21.  
  22.     void reset();
  23.     
  24.     void start( const ColorType side );
  25.     
  26.     void pause();
  27.     
  28.     void resume();
  29.     
  30.     void stop();
  31.     
  32.     void update();
  33.     
  34.     void count_up();
  35.     
  36.     void count_down( time_t limit, const ColorType side );
  37.     
  38.     time_t get_limit( const ColorType side ) const
  39.     {
  40.     return limit[side];
  41.     }
  42.     
  43.     time_t elapsed_time( const ColorType side )
  44.     {
  45.        return etime[side];         
  46.     }
  47.     
  48.     time_t time_left( const ColorType side );
  49.     
  50.     // a not-running clock may be stopped or paused.
  51.     Boolean is_running() const
  52.     {
  53.         return running;        
  54.     }
  55.     
  56.     // a stopped clock can only be reset.
  57.     Boolean is_stopped() const
  58.     {
  59.         return stopped;        
  60.     }
  61.     
  62.     // True if one side has exceeded the time limit
  63.     Boolean time_is_up() const
  64.     {
  65.     return time_up;
  66.     }
  67.     
  68.     void show_time( ColorType side );
  69.     
  70.     ColorType get_side_to_move() const
  71.     {
  72.        return side_to_move;        
  73.     }
  74.  
  75. private:
  76.     HWND pWin;
  77.     Boolean running, was_reset, stopped, time_up;
  78.     time_t etime[2];
  79.     time_t last_start[2];
  80.     time_t limit[2];
  81.     ColorType side_to_move;
  82.     Direction dir;
  83. };
  84.  
  85. #endif
  86.  
  87. extern Clock *the_clock;
  88.  
  89.